package br.com.abril.task;

import org.apache.log4j.Logger;

import br.com.abril.job.AbstractTask;
import br.com.abril.job.Job;

import com.force.abril.prevision.download.PrevisionServiceActivator;
import com.sforce.ws.ConnectionException;


public class PrevisionTask extends AbstractTask  {
	
	private static final Logger logger = Logger.getLogger(PrevisionTask.class);
	
	private PrevisionServiceActivator service;
	
	public PrevisionTask() {
		service = applicationContext.getBean(PrevisionServiceActivator.class);
	}

	public PrevisionTask(Job job) {
		this();
		setJob(job);
	}

	@Override
	public void execute() {
		try {
			service.downloadPrevisions();
			logger.info("................ Download Prevision completed");
		} catch (ConnectionException e) {
			logger.error("Unable to Connect to SalesForce", e);	
		}
	}
	

}
